package models;

import java.util.Date;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.Transient;

import play.db.jpa.Model;
import flexjson.JSONSerializer;
import flexjson.transformer.DateTransformer;

/**
 * Contract 合同
 * 
 */
@Entity 
public class Contract extends Model {
    
	
	@ManyToOne
    public Project project;

    public String contractNum;   //合同编号

    public String partB;         //合同乙方单位名称

    public Date SignedTime;     //签订日期

    public String subject;      //合同标的 

    public Integer count;        //合同数量

    public Double price;        //合同价

    public String selectedMode;  //合同确定方式
    
    public String changeInf;

	public String remark; //备注

    public Date createdTme;  //创建时间
    
    @Transient
    public Long projectId;
    

    public Long getProjectId() {
    	return project.id;
	}

	public String toString() {
        return "";
    }

    public static String toJson(List<Contract> contracts) {
    	return new JSONSerializer()    	
    	  .transform(new DateTransformer("yyyy-MM-dd"), "SignedTime")
    	  .include("id","contractNum","partB","SignedTime","subject","count","price",
    			  "selectedMode","remark","projectId","changeInf")
    	  .exclude("*")
    	  .serialize(contracts);
    }
    

}